<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
	<head>
		<meta name="author" content="Bardelle Renzo"/>
		<title>Login</title>
		<meta http-equiv="Content-type" content="text/html" />
		<link rel="shortcut icon" href="css/images/favicon.ico" />
		<link rel="stylesheet" href="css/style_global.css" type="text/css" media="all" />
		<link rel="stylesheet" href="css/login.css" type="text/css" media="all" />
		<script type="text/javascript">
			<% if(session.getAttribute("utente")!=null) out.print("window.location=\"../index.jsp\";"); %>
		</script>
		<script type="text/javascript" src="jQuery/jquery-1.9.1.min.js"></script>
		<script type="text/javascript">
			function submitLogin()
			{
				var dataString = 'email='+$("#email").val()+'&password='+$("#password").val();
		
				$.ajax({  
 					type: "POST",  
 					url: "../verifica-mail-password",  
 					data: dataString,  
 					success: function(response) 
 					{
 						if((""+response).length>0)
   				  		{
   				  			$("#messaggi-utente").html(response);
   				  		}
   				  		else
   				  		{
	   						window.location="<% if(request.getHeader("Referer")!=null)
										out.print(request.getHeader("Referer"));
									else
										out.print("../index.jsp");%>";
	   						return false;
   				  		}
 					},
 					error: function() 
 					{ 
       					$("#messaggi-utente").html("<font id=\"error-message-title\">"+
							"Problema di connessione al server</font><br><br>"+
							"<div id=\"error-message-body\">" +
							"Si prega di verificare i dati inseriti e ripetere l'operazione di \"Conferma\".</div>");
 					}
				});  
				return false;
			}
			
			function toIndex()
			{
				window.location="../index.jsp";
			}
			
			function clearMessages()
			{
				$("#messaggi-utente").html("");
			}
		</script>
	</head>
	<body>
		<div id="wrapper">
    		<h1 id="logo"><a href="index.jsp" title="Hesperia.com" ></a></h1>
			<!-- LOGIN MENU -->
			<jsp:include page="login_menu.jsp"/>
			<!-- End LOGIN MENU -->
			<!-- MENU -->
			<jsp:include page="nav_menu.jsp"/>
			<!-- End MENU -->
    		
    		<div class="shell">
        		<!-- Main -->
        		<div id="main">
            		<!-- Box-Holder-->
            		<div class="box-holder">
	            		<div class="box-top"></div>
	                	<div class="box">
	                		
	                		<!-- LOGIN FORM -->
							<div id="login-main">
								<div id="form-div">
									<form action="" onsubmit="return submitLogin()">
										<table id="form-table">
											<tr><td>E-mail:</td><td><input id="email" type="text" name="email"/></td></tr>
											<tr><td>Password:</td><td><input id="password" type="password" name="password" onkeydown="clearMessages()"/></td></tr>
											<tr><td></td><td><input id="submit" type="submit" value="Login"/></td></tr>
										</table>
									</form>
								</div>
								<div id="vertical-line"></div>
								<div id="registration">
									<br/>
									Non sei regisrato?<br/>
									<a href="registrazione.jsp">Registrati qui!</a>
									<br/><br/>
									Hai smarrito la password?<br/>
									<a href="mappa_sedi.jsp">Contatta una delle nostre sedi!</a>
								</div>
								<div id="messaggi-utente"></div>
							</div>
							<!-- END LOGIN FORM -->
	          
	            		</div>
	            		<div class="box-bottom"></div>
	        		</div>
            		<!-- End Box-Holder -->
        		</div>
        		<!-- End Main -->
        		<!-- Footer -->
				<jsp:include page="footer.html"/>
        		<!-- end Footer -->	
        	</div>
        	<!-- End Shell -->
        </div>
        <!-- End Wrapper -->
	</body>
</html>